//
//  CourseDetailCell.m
//  HTP
//
//  Created by admin on 15/11/11.
//  Copyright © 2015年 nit. All rights reserved.
//

#import "CourseDetailCell.h"
#import "NSDate+FSExtension.h"
#import "CourseRecordDetailModel.h"
#define COURSEDETAILCELLHEIGHT 125
#define Padding 5
@interface CourseDetailCell()
@property (nonatomic,retain) UILabel *codeLabel;
@property (nonatomic,retain) UILabel *dateLabel;
@property (nonatomic,retain) UILabel *courseLabel;
@property (nonatomic,retain) UILabel *teacherLabel;
@property (nonatomic,retain)  UILabel *orderCodeLabel;

@property (nonatomic,retain) UIImageView *statusImg;

@property (nonatomic, retain) CourseRecordDetailModel *courseRecordDetail;
@end
@implementation CourseDetailCell
-(void)_initUI{
//    _orderCodeLabel = [self getNormolLabel];
//    [_orderCodeLabel setFont:[UIFont systemFontOfSize:18]];
//    _orderCodeLabel.text = @"订单号:";
//    [_orderCodeLabel setFrame:CGRectMake(Padding * 2, Padding, [_orderCodeLabel.text textSizeWithFont:_orderCodeLabel.font constrainedSize:CGSizeMake(ScreenWidth - 100, 30)].width, [_orderCodeLabel.text textSizeWithFont:_orderCodeLabel.font constrainedSize:CGSizeMake(ScreenWidth - 100, 30)].height)];
//    [self.contentView addSubview:_orderCodeLabel];
    
    UIImageView *imageLine = [[UIImageView alloc] initWithFrame:CGRectMake(0,20, ScreenWidth, 1)];
    imageLine.image = [UIImage imageNamed:@"line_h"];
    [self.contentView addSubview:imageLine];
    
//    _codeLabel = [self getNormolLabel];
//    _codeLabel.textAlignment = _TEXT_ALIGN_LEFT;
//    [self.contentView addSubview:_codeLabel];
    
    _dateLabel = [self getNormolLabel];
    _dateLabel.textAlignment = _TEXT_ALIGN_LEFT;
    [self.contentView addSubview:_dateLabel];
    
    _courseLabel = [self getNormolLabel];
    _courseLabel.textAlignment = _TEXT_ALIGN_LEFT;
    [self.contentView addSubview:_courseLabel];
    
    _teacherLabel = [self getNormolLabel];
    _teacherLabel.textAlignment = _TEXT_ALIGN_LEFT;
    [self.contentView addSubview:_teacherLabel];
    
    _statusImg = [[UIImageView alloc] init];
    [_statusImg setFrame:CGRectMake(ScreenWidth - 80, 125 - 70, 60, 60)];
    [self.contentView addSubview:_statusImg];
}
-(void)layoutSubviews{
//    [_codeLabel setFrame:CGRectMake(CGRectGetMaxX(_orderCodeLabel.frame)+15, CGRectGetMinY(_orderCodeLabel.frame), 100, CGRectGetHeight(_orderCodeLabel.frame))];
    
    [_dateLabel setFrame:CGRectMake(Padding * 4, 35, ScreenWidth - Padding * 8, 20)];
    
    [_courseLabel setFrame:CGRectMake(Padding * 4, 35 + 20 + Padding*2, ScreenWidth - Padding * 8, 20)];
    
    [_teacherLabel setFrame:CGRectMake(Padding * 4, 35 + 20 * 2 + Padding * 4, ScreenWidth - Padding * 8, 20)];
}
-(void)setCellData:(id)cellData{
    _courseRecordDetail = (CourseRecordDetailModel *)cellData;
    if ([_courseRecordDetail.cgcStatus integerValue] == 2 && [_courseRecordDetail.crAccess integerValue] > 0 ) {
        [_statusImg setImage:[UIImage imageNamed:@"done"]];
    }else{
         [_statusImg setImage:[UIImage imageNamed:@"doing"]];
    }
    [_dateLabel setText:[NSString stringWithFormat:@"时间: %@ %@-%@",[[NSDate fs_dateFromString: _courseRecordDetail.cgcDate format:DATEFORMATT] fs_stringWithFormat:@"MM月dd日"],_courseRecordDetail.cgcStartTime,_courseRecordDetail.cgcStopTime]];
    
    [_courseLabel setText:[NSString stringWithFormat:@"课程: %@",_courseRecordDetail.courseName]];
    
    [_teacherLabel setText:[NSString stringWithFormat:@"教师: %@",_courseRecordDetail.teacherName]];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
